Refactored to make configurable and avoid leakage. Smaller than jQuery :)