fix a bunch of bugs and update knex