use better debug messages, fix possible printf syntax error