A few fixes.

See commits for more information.