Fix #1. Special-case PNGs. Also, minor changes and cleanup.