Fixed #36. Break down the pre_process() into smaller static functions.

However, I am not sure did I do it correctly as the broken functions just simply check for condition.