Various adjustments. Separate commit for easier review. Intend to squash.