Merge dev-alap and refactor to use helpers

This PR merges the code Alap pushed for retrieval and includes a refactor of create and insert code to use helper methods.