Implement breakLoop.

Also slit Capture into Live and Replay.
Refactor JavaScript code.

Split into separate modules.