flask rearrangement, everything is broken