Core/AI: Some code cleanup