Refactored associate() to avoid nesting promises

This also makes it cleaner and allows to easily pluck the handler functions out,
which I may or may not do.
Added workaround for using the plugin on the CLI

Not really smart, but it works.

Fixes #2