Fixes issue #403.

Based off of PR #489.  Should probably be merged after that one.

Closes #403