Cleanup. Removed all warnings by casting to the appropriate type.
Added serialization and deserialization to JSON code.