Fixed some bugs in visit recording