Bug fixes

This was only supposed to be one commit but apparently I didn't pull in my previous commit before making this one. Oh well.