Fixes for #50 and #52

I'm not entirely sure that there are the "best" solution, but they work and pass the tests.