Added a new next_client() function and made some tweaks to remove compiler warnings and checkpatch.pl warnings.