Rewritten to use jQuery.widget()

This makes everything more consistent, allows future improvements.