Minor bugfixes and remove noisy debugging messages
Reformat to 120 characters per line (easier to read) and other style cleanups