added some error checking to thread_create and _add_runqueue