fixed #14 #15 & other bugs