Cleaning up some messy code.