First pass of cleanups + security added checks (mainly querystring parameter to int casts)
Merge pull request #1 from ggam/cleanups

Code cleanup