code refactor

fix logic with signed/unsigned integer comparisons, handle all
comparisons with approved function
code refactor

remove int casting in printf functions and in other places