Updated the serialisation code to include namespace definitions