avoid potential startup order issues
tidied up the logging
simpler more reusable code