Moved all functions to OS thread