Refactored main instance class