Improve the way that we do debugging

This approach to debugging allows us to keep line numbers. Declaring functions within blocks is technically a syntax error: use a function expression assigned to a variable instead.

BTW, there was also some whitespace clean-up done, so use ?w=1 after the diff URL to see the semantically significant changes.