Fixes #21. Found some other bugs on the way...added them to issues list.