Fix many warnings about unused variables.
Fix misuse of STACK2LIST macro that was crashing.

STACK2LIST was adding the first two arguments to the list of database
pointers. This was very very bad.

Reported by Radu Andries.