I did a typo. Here is a fixed version, also includes a few minor clean ups I missed.