Fixed sql, minor style and ajax call changes