clean up some messy code