Extra check to avoid lending a book when some people are already waiting.

There are some reports of this happening.
Added debug_info to loans for trouble shooting.

It'll help identifying the situation better when next time a book is loaned
out even when there is waiting list.