Dipolar molecules in optical lattices