fix header and some bugs