Logic almost done.