better legends; debug flag