Incorporated fixes from Bryan