began improving flattening
got calibration properties working better
code modification
finally got flattening modularized!