Effect of Modularity on Evolution in Heterogeneous Environments