Various modifications. Checked in to port to the tier3.