fix #41 and #39

There are some plugin api changes from idea 13 to 13.1 and I made some code changes that I believe won't compile in 13.  If you still need to support versions before 13.1 on master then please create a '13.1' branch and I will send another pull request.