Fix some corner case issues