2287: code arrangement

refactor and arrange source code
2289
2294: move code ...
2295: move code
2302: move code ...
2303
2304: update sample file
2305: fix BoxSpec Inherit Err
Merge branch 'v1.7dev' into v1.7