integer overflow and some other bugs