add commandline magic and refactor useless variables