Fix Dict insert bug by using generalized balance function

Also removes now dead code and rearchitects a few things to statically
eliminate possible future bugs.
Merge pull request #445 from maxsnew/dict

Fix Dict Bug