fixed most bugs