Improve the logging mechanism for objects

The logging mechanism now exposes a FILE* for fprintf
Never deference a null (rsm) object when destructing it.