Add transactions. Forward debug flags to controller. Fix bug in Sql/Model for back-compatibility