fixed some issues #56, #55, #46, #39, #12