add command line option to start up in maintenance mode
some bgsync refactoring