Add changes suggested by Gerd and fix another short-lived java invocation