refactor Create Package to make sure undo works correctly (PY-1829)