Some cleanup, plus fixes.