Updated table names and references

Updated the table names in the install scripts
Fixed all of our sql_constants functions that had hard-coded table
names.
Cleaned up some code formatting while I was at it.