Cleanups, minor fixes, better debugging messages.