Tweaks and refactorings