Fixes #18. Still not perfect.