Added Serialization and fixed a few ML bugs