corrected a number of potiential code issues