Removed jquery dependency

Refactored to reuse code and to support more types of environments in
the future