Significantly refactored core classes for easier serialization