random npid generation (untested properly, but i think it works), and some error handling for the listeningthread

otherwise, only other change is the addition of the error class in log