Improve checks and initialization logic