Cleaned up the code and fixed bugs

This module is now compatible with the jQuery API, but still a lot of
work remain