Merged our changes in one

I have done some code reorganize, and also fixed back my enum column logic that has been broken after the merge.
It took me some efforts to merge all of those with your new changes, but I believe that it will be helpful for our further work.