Replaced encodeURI with encodeURIComponent; added class methods; and added support for callbacks