Added fixes to some edge cases