fixed a lot of small bugs