lib: fix shadowing and wrong variable type