Fixes for a couple of issues I have encountered

See the issues themselves and the commit messages for more information.