Implement AI and fix merge conflicts