fix most bugs