perl and minor fixes