added legend; cleanup