Shadows compositing

I would like to finally solve this old issue.

During product design viz is sometimes required to composite objects against a neutral and flat background.

I achieve the best results using matte object with the settings attached but I always have 2 problems:

1. shadows don’t exactly match the original image
2. it always requires me to render 2 images: the first one for the correct rgb (matte unchecked) and the second for the correct alpha (matte checked); that’s because using the second alpha with the second rgb doesn’t return the right shadows

Any idea to improve the shadows and get the job done in one pass?

Thanks in advance

Could it have something to do with linear/gama workflows.
Have you tried compositing in linear space ???

maybe try my trick for reflection but with shadows:

http://www.chaosgroup.com/forums/vbulletin/showthread.php?53264-any-way-to-get-reflection-on-matte-object