Mri upload optimization

This pull-request contains further optimization.