Added a few missing comment blocks and cleaned up code a bit