Added flag and power persistance to sql.