Add debug logging (will be useful for tracking issue #57)