FIXED: Make the dbg_print correctly call out to external C code even if called from CPP code.
	Remove code duplication.
FIXED: Some format statements were wrong. %x instead of %lx
This also reduces the amount of compiler warnings.
Added two FIXME to correct output later for more complex types.