refactors, including using decorators for serialization, which fixes #2