killed some more bugs and polished the code