Wrap the database queries in a transaction to improve performance, and
delete a heap of now redundant code.
Cache the downloaded data untill it is out of date
General cleaning up of code