Some fixes and a small cleanup.