Let's try that again. Fix for #460, should perform well and be properly threadsafe.

Signed-off-by: Ross Allan <rallanpcl@gmail.com>