fixed SQL issue and various DataAPI issues