Fixed API issues with SQL