Integrated the changes from Ajai to make it ready for final version.