SQL tweaks: table better suited to actual data.
Cleanup.

No useless variables ;
Better conformance to PSR-1 and 2 standards.
Merge pull request #1 from PierreLvx/master

SQL tweaks + code cleanup.