Further AI improvement. Removed some more constants. Added more tests.