cleanup (removing work_available, adding free(), etc.)