adjust the code layout, and add db update support.