General improvements, smaller refactorings