Fixes/improvements to content negotation

See Changes and commit messages for details.