Fixed some bugs

Bugs still exist! If anyone wants to also work on this, here it is.