Fix global variable leaks. (And turn on leak-checking in mocha.)

Closes gh #13.