Mechanically (more or less) converted javascript to use sc namespace