Bunch of fixes to memjs

Review individual commits.