Refactor java core