added some error handling and liq object destructor functions