Moving legend generation to separate module. Still in progress.