Clean up some awkward code