Microstructure and impurity phases control in the synthesis of LiFePO4