tidied up function so that they all return codes to the calling function when they finish properly. the graph presented in the documentation is now more easy to follow and represents the structure of the preprocessing.