Cleaned up and commented in AI