Fixes for a couple of issues

If I didn't misunderstand anything this should fix #29 and #31