Fix analyzer complaint

Some casting and declaration issues