fixed a bunch of small bugs