Updated with Jay's fixes.