Fixes #403. Not perfect but good enough.

God this is cool.