Update for newer version of AE, make threadsafe