safety check before init and some tidy work