Some minor fixes for edge cases