Tidying up the main script and splitting out the code into includes. Using CDNs for JavaScript where possible.