Added error return to task_create
Added error checking for event_wait