Improved hook to prevent multiple queries.
Merge pull request #184 from iamntz/class-hook

Improved hook to prevent multiple queries.