Added main function and cleaned up the optionparsere