Custom CLI arguments parser, put log in a separate file, and several bugfixes