Added insertion/deletion support, fixed several bugs.