fixed #1 and a few other things