fix issues with saving nested objects