Fix minor bugs discovered when testing.