Rewrite SetStartupFlags()

This piece of code was so poorly written that I was scared to change it
in fear that it actually did some magic that I couldn't fathom.

Spoiler alert: it didn't.