Curl fixes, small refactorings.