Fix autostart toggle bug, consolidated some functions

Fixed toggling autostart which was broken last commit.

Consolidated some functions which were only called from one place and
  honestly work more elegantly when merged together.