bugfixes by Nathan