Refactored and fixed checkstyle errors