corrected a lot of bugs