WriteSQL and sime fixes