Argument parsing and some work on the encoding func