fixing some bugs, but there are a LOT of them