Refactors js into two classes.