Hopefully fixed #62.

Somewhat tested, but may not entirely work.