Refactored some things