Cleanups & expressions

Continuation of Tomaz' work on #3790, which this replaces. Also includes:

1) Further expression fixes
2) Minor fixes to mime-mapping handling
3) Correction to the incorrect default for the redirect-port attribute (AS7-5871)