Tweak formatting and add more code comments