fixed a lot of bugs and stuff