Added changes to run with use_new_orm=1