AI added. Code tidy.