Check for resourceId parameter before defaulting.

I had a problem where I had to use Babel from outside any resource and that broke it since current resource ID was fetched before using the passed parameter. This refactoring takes the parameter first and then current resource ID (if a current resource is present).