Fix callback and tidy up formatting

Fixes the callback mechanism (-c), and applies some formatting fixes
to the code.