Fwd port: Small macro fixes and code cleanup
forward port of fc064f21e5ef2379dc9216b0ba3e46f11a3563f2 from old kde-runtime repo