Latest code changes from Sharad + Brian