Invalid Index, DB Query, and other functions updated.

Fixes many a small glitches introduced when trying to solve the
problems found when installing Noteworthy on some shared hosting
servers.