Fix problems with length, make division by zero return null