Junhao refactor and gui support