Refactor callbacks for handlers so they can be used with Java 8
lambdas and JavaScript and also to cut down on code.