Resolve some unchecked casts