Refactor classes and structures