fix a lot of bugs...