Pattern output cleanup; program cleanup