General libutils modifications and adding Queue

It was pointed out that certain operations in RefCount should use ProgrammingError instead of returning error codes.
This pull modifies those operations and updates all other structures and tests. The queue implementation is updated too.