Some cleanup, some bug fixes.