Added more memory fixes.

More memory fixes which were caused because of no initialization.
A few printf relocations
Added many debug flags and formatting of debug messages.

Added named debug flags that are #defined and formatting of debug messages with proper error redirection.