D5 & R7 used to go from 24v to ground. Then you moved things around. Now DS & R7 are in the path from 24v to the 7805 regulator input. It will not work very well like that, as you have discovered.