Some cleanup. PLease never touch find_rect or find_corners. Thank you.