Cleaned up, and refactored