Added file header. Optimized output. Minor other changes.