sql fixes/updates/streamline