Fix build errors because of not included file.

Plus improve code layout.

Refs #7557
Merge branch 'feature/7557_muon_rm_tmp_file' into develop