Reformat code and extended checkstyle

Added many checkstyle rules.
Reformat code with IntelliJIDEA.
Solve some checkstyle warnings.