Created serialization abstraction. Fixes #20.