Trim optimizing enhancement

Enhancement for #98.