Refactored towards proper class design