Changed preprocessing so its callable both from command line and python in a convenient way.