Code alignment and other adjustments
Further code adjustments.
Added debug messages.
Added documentation
Code alignment
Documentation