cleaned stuff up; added more comments