Fixed code to properly use select(), the system no longer needs threads. Not yet tested :(