Reorganize variables and contexts and add externalization paramFile and logDir