Fixed quite a few places where I used  instead of __PACKAGE__

Most functions in this module are now intended to be exportable, and so
I can't rely on  being passed as the first argument.