Improved threading to make the whole client in background