Added proper prepare to haval.  Also split up to have 2 valid functions