Restructure SQL classes a bit