Influence of residual stresses on fracture and delamination of thin hard coatings