Refactored QueryContext to be Scala instead of Java