fixed some bugs, probably added some more