Fixed 500 errors.
Changed mysql to use prepared queries to prevent sql injection.
Added comments to team profiles.
Improved button handling on team averages page.
Moved team averages backend code to separate page.
Cleaned up misc code.