Improve performance

Offloaded heavy lifting to a thread