fix to serialisation and other minor fixes