Fix some insert and overwrite bugs.