Fixes #288

I had to totally rewrite ```caps.js``` because it used global variables which overwrote each other when running multiple accounts at the same time.