Clean up inserts code