Cleanup and added serialisation to json