re-package

group codes by function, get prepared for further UI improvment.