Fix most byte compilation warnings

Byte compilation of `merlin.el` produced a few warnings, including a bug. Although the free variable warnings are usually harmless, it's better to clear them out.