Insert composition refactoring and bug fixes