Bug fixes in insert.