Fixed some SQL stuff