fix some compiler warnings seen with -W -Wall; rearrange code into logical sections
fix some compiler warnings seen with -W -Wall; rearrange code into logical sections

cention-nazri/libdbi-drivers,cention-nazri/libdbi-drivers,cention-nazri/libdbi-drivers,cention-nazri/libdbi-drivers