fixed a lot of weird bugs