fix issues #5, #15, #17