Fixed argument parsing and other bugs