ask server for flag, fix some bugs