Modular Invariance and the Flavor Puzzle