Edited insert etc

Edited a bunch of random stuff. Seems to work fine as far with the test files, except occasional stackoverflow on search.