Migrate Treatment Completion variables to database and fix some routes