Some database lookup optimisation using select_related and moving lookups to view.
Some minor fixes.
More db lookups moved to view.
Further optimisation, mainly through select_related statements.