Cleaned up messy code.