Skips some unneeded initialization.
There was no need for static variables in this function. Code more thread safe.