Refactored JavaScript

This approach may help organize the functions better. Entering the
namespace in a debugger console ('SC' for Star Chamber) allows you to
explore the object as well as makes it easier for testing.