A few sweeping changes were needed: - Avoid use of HEREDOC, which does not seem to work. - Avoid extra '.' in paths by using '_cmk' and '_tmp' instead of '.cmk' and '.tmp'.