Fix error-throwing code

Fixed two parts of the codebase that were throwing errors to the console due to improper handling of jQuery and jQLite wrapper objects (see the commit descriptions for more info).