minor changes (mostly static type casting) to match with master on GitHub.  pain in the ass to implement (by KDiff).