Use gnulib xalloc to allocate memory where possible.
Reformat else's for compactness and legibility.