Added optimization and code fixes according to checkstyle 5.7 check.