added expantion options for reverse lookups
fixed a couple bugs from the cleanup of the SQL statements