Migrated argument parsing to another file

    * also cleaned up the code and fixed some errors