Dhm/acid aside

@cpennington review (incorporates the other PR and I may should move some of these into that other one)
I know only rudimentary Javascript - I've looked at these changes but have not been able to review them for correctness.