fixes for some edge case bugs