Refactor initilization and validation.