Numerous tweaks and bug fixes.