a few bugfixes imported from neo github subdir