Refactored some bad stuff.