Replaced some magic numbers with constants from mysql_com.h
Changed the way query.done is set.