Added serialization, other code and simple tests