Bug fixes

Merged Wolfgang's fixes for Ubuntu