Runtime type cast error and checkstyle fixes