Some fixes, almost finished cleanup.