Fixing warnings and removing unused functions , variables