Reformatted code and commented.