SQL Fixes

Bug fixes and getting SQL to work
Removed debug file