added killAlphaThreshold
only allocate tmp memory once and when needed