Implementing three factory modes: singleton, thread local and unrestricted