Safety optimization through risk management