corrected a lot of bugs and problems