Code refactoring.

Same end effect, but now the code is structured the way a jQuery plugin should be.