Cleaned up, refactored code.