Refactoring of instance related operations with cleanup and bug fixes