The independent sector assumption in the CreditRisk+ model has been a major bstacle to its implementation. Attempts to overcome this limitation have not met with much success. This paper proposes an extension of the original model that accommodates a wide range of sector covariance structures. Existing numerical algorithms designed for the original model can be reused with little modification. Case studies demonstrate that our model outperforms other CreditRisk+ variants that allow sector dependency. A simulation version of our model is also introduced, which is in turn used to find an optimal portfolio allocation based on the work of Andersson et al. The simulation error is very small compared with the model's analytic counterpart, and the optimization significantly reduces portfolio credit risk.