Flattened the directory tree of the code, factored out some common parts
Factored out more common stuff