fixes to most bugs