Fix issue#12: NPE when multiple threads allocating ID