Added better download management and cleaned up code, comments to be added soon