refactor serialization switch to all subclasses with serialize isEmpty and cleanup
add tests for that