flags are now indexed, fixed some problems with the mapping