smaller bugfixes and partial vectorization