PERF: small changes for slightly faster computation