Cleanups: Just shorten code
Cleanup: More readable way to generate the results HTML page
Cleanup: Search object should know how to display its search terms

Also the use of properties allows us to have a cleaner code.
Cleanup: Search object should know if it has an invalid search term
SQL cleanup

Use uppercase, span several lines to improve readability, use
implicit line continuation, invert quoting to avoid escaping.
Cleanup: Invert quoting to avoid escaping
Cleanups: Indents, whitespace and long lines wrap
Cleanup: Remove unnecessary function
Embedded HTML cleanups to improve readability

* Move template context retrieval to the top of the code block,
* Use format() to avoid mixing string with variables,
* Use implicit line continuation instead of endlessly concatenating strings,
* Use print as a function.

This a previous step to strip out the HTML into proper external templates.
Cleanup: Remove unnecessary function
Cleanup: Move complexity to another function