Pyflakes integration

Pyflakes integration (also includes previous fixes and requested sql validation fixes)