Revert to 5221ba74db87c199e0369cd5d9ded31b0100af9c

This refactoring broken too many things. The refactoring
work shall continue in the refactor branch instead.