Fixed some bugs in flagvector