Changes by @jdarling

(untested)