Improved code for long and short opts parsing