Various improvements and fixes.