Refactor "globals" g_... to oni..., as they are now members.
Cleaned up initialization and return code checking code.