changed condition variable's wait method to return bool; updates to takeRequest for eliminating deadlocks and with better error handling