Major refactoring of class structure