Bug fixes, some clean-up.