Fix some more edge case bugs