Fixes to implementation of insertion.