Some code tidy-up before pull request

Fix build failure.
Fix some indentation issues.
Remove some comments/notes to myself.
Merge some CStdString and the = PrepareSql lines.