Updated with minor fixes (thanks, @garrettr!)