fixed memory leak related to wrong reference counting on empty queue