fix dirty casting flagged by clang