htomasz's fixes