fixed github issues #5, #12, #15, #17