Major refactor to remove dependency on jQuery.