fixed update problem when inserting node, also did some performance opts and clenups