Add partial save support and overall refactoring