Fix cppcheck warnings (with exception unused functions)
Replace dynamic casts with object casts