Added legend; reordered code (nothing critical changed); Fixed ruler text.