Converted a bunch of processes into helper functions. In the motto of Java - write once debug everywhere.