rewrote sql queries with proper PDO binding
fewer sql queries, unique phrases in index
typo
merged termhandler in capture/common/functions.php