SSMEG script with general preprocessing functions