ai fixes and bug fixes