Optimizations to HHJ and introduced some unit tests.