Cleaned some messy code