SQL somewhat rebuilt.