Minor fixes and further progress on save function.