Fix bugs causing infinite loop in gllost, add more logging.