Refactored JS libary and small API changes.

The outputs API no longer provides the layer count for each output. This is now provided once by the controller API.

The JavaScript lib has been refactored to have less dual-purpose functions.