bugfixes from paul