Some fixes from Christoph Deil