Refactored lots of code to make way for scanning the repositories table.
This commit leaves code not fully functioning, as the downloading needs
to be implimented.