Moved functions inside class declaration

Moved many of the helper functions inside the class declaration so that
they can access the class properties such as url and basicQ. This allows
the class to be called from another class or script.