move sqlalchemy sessionmaker out of settings file. seems cleaner this way.
check for format or aggregate status in query field before tree level
since tree level is only indicated by noncorresponding field names was
causing a bug.