rewrite the core structure

Signed-off-by: August Yip <augustyip@ecvision.com>