Refactor classes to untangle dependency and clean-up architecture