Add Java implementation of JavaScript too, cleanup code