Some Source Code that might work for you - MPGH