Initial checkin - minor tweaking from original code