bugfixes to inserts, removed useless code