fNextObjectNumber was not initialized.
Refactor some code.