Cleaned up the AutoHP/MP code

untested because of no compiler