Fix bugs #1 and #2

Fixes for bugs discovered by panurge-ws