Properly scope variables in after/plugin file

Closes #1.