More efficient portable threadsafe dictionary implementation