Sqlalchemy fixes after develop branch merged [WIP]

Work in this PR is in progress. There are several tests that are now failing after merging with `develop` branch.