Fix some issues identified by static analyzer

Includes "printf format" annotation on debug log function.