Various cleanups and a couple fixes.