Refactored to support cljs/cljx. cljs test not passing.