Revise to conform to Xapian code style and some fixs