Sql fixes.
Change app a bit.