Fixes for issue #10, issue #13 and issue #15