Small bug fixes

These are untested but I see no reason why they shouldn't work.