Big fixes and cosmetics

Minor changes all over the place.