Several changed/fixes applied from Peter-Rumpler