Fix coordinates module

For some reason it all was stashed inside a class. Not sure why.
Separate data collection and writing

This takes more memory but makes it possible to perform transformations
on the data before writing it.