Serialisation

new serialisation code splits data into files and is more robust and extensible