Fixed most bugs