Refactored code, splitting into individual classes