Externalize functions in a common file

We use the same functions over and overs, so it should make our life
easier if we externalize these functions in a file, making it
unnecessary to copy-paste code over and over...
Removing the calls from the single analysis files