Code simplification, and make sure the ordering is correct.