Update #3 v2.2

* Sync with master #2
* improved code design