Added missing debug include.
Fixed broken macros, now using braces before dereferencing.
Removed use of malloc / free in rlgr.
Added missing function declaration.