* use elog not ereport for debug * fix debug levels for some output * properly check for memory allocation errors in a couple of missed places