Updates to functions, db.sql and postprocess_threaded