Halved rendering time.
Added guards for values that must be positive in allocation algorithm.