Change logging level to debug
Refactor functions to objects
Update JS for changes from previous commits