Added proper restart handling (new config data is automatically loaded after restart).
Minor refactoring.