Sometimes when I flatten a file it get's darker. I am using various blending modes on different layers. Could that be the problem?
Yes. Combining various blending modes can result in unexpected results.
Try merging your layers one at a time.
Link the top two layers.
Choose Layer > Merge Linked.
Continue linking and merging one layer at a time.
If at any point in the process, you encounter a density shift (image gets darker) undo the merge.
File > Undo.
Add a new empty layer (Blending mode set to Normal) below the problem layer.
Link and merge ithe problem layer with the empty layer.
Repeat the process if you run into further problems.