bugfixes (thanks to chris)