Clean up insert function.