Changes converting to Titanium 3; minor refactorings