Improved checking if a file is a plugin.

Closes #322.