Replaced more than 100 lines with 10.

Calc3d is now much faster and can handle more than 1000 layers if
needed.
trying a new quantize Routine
revert

h
Revert "revert"

This reverts commit 9c322aad1d9f62d3439350d322d100d7861a76b1.
Minor Changes
More Minor Changes
Merge remote-tracking branch 'origin/NickBranch'