refactor the logic of initialization to avoid issues caused by edge cases; add options for start on boot