Attempt to fix up some stuff regarding scanning and browsing bugs
extreme database changes, sqlamp, using session for all queries,
scanning refactor