small condition optimizations in various functions