Reformat code and add checkstyle rule