Refactored most things