update from paul with bugfixes