Js amberdb upg

Upgrade to the latest version of AmberDB.  Requires minor refactoring in places.

@JonathanShaw you probably want to see this...