Fixing issues when invoked from CLI