...

Closes #919.

I don't have time to modify this further, so please review on a binary basis. (i.e., is it better than what's there now?)