Understanding and Improving Model Averaging in Federated Learning on Heterogeneous Data