Fixed errors in the dispersion writter.

Coupling for elements fixed as well.
Removed some PEP8 warnings.