Java rewrite engine2

mainly, fixing the list matching.