more clean up; cmdline works

Fixed a few bugs, e.g. self.percent_to_hex and fixed command line import.