Removed cumbersome callback API for serialization. Cleaned up style.