Refactored some stuff