Remove old code
Fix crash-on-daemon-shutdown bug