bug fixes for some edge case errors