Fixed legend bug, minor changes