I just sold my 40 after picking up the 50. And I also have the 24 STM, from what I noticed while shooting the 40 is a great lens and is sharp wide open @ 2.8. With that in mind the 50 is just as sharp when shooting @ 2.8 or even wider if needed. I only sold the 40 because it seemed a bit odd to have a 40 and a 50, and I bought the 50 for the times when I might need a little more LL capability. I love the STM lenses and i have gotten great shots with the 24, 40, and the 50.
The 24 STM is a great lens for crop bodies IMO.