Added logging, tweaked sqlalchemy logic;