Will be easier to parameterize mode than to manually go through the steps each time.
Made changes in obvious places.
Some finishing touches.