Bug fixes and enhancements

You should totally get this commit.