Removed un-used variables, trimmed unnecessarily explicit name-spaces, fixed SQL data-type typo, fixed accidental variable trampling and highlighted some potentially subtle SQL data-type bugs.