Fixed some checks that would otherwise fail on empty collections