Improve generating java/php code