Several fixes for issue #21.