Here's a good piece on debug: Debug routines