FELIX-1477 Apply slightly modified (formatting) patch by Andy Wilkinson (thanks alot !) to make the implementation more thread-safe