bug fix and move SQL to its own folder