init PrevieState; fix missing tablefunctions in main