Reformatted a good deal of code and added a good deal of comments. Also changed switch statements to else..else if...else statements