Improved error handling for options -x and -g