Moving existing code into folders

Moving existing code into folders to reflect what they do.
Made detection code less reliant on config files.