Fix view engine && minor refactor