edited scripts to reflect new database schema, various bug fixed