move some code to header file, update configure.ac