Latest AI code with fixes. Contains rom error.
Merge with AI code.