fixes

Integrated fixes from RT patches, Stephan Jauernick's fork.