fix a lot small bugs