Some further fixes and cleanups.