Refactorings and tweaks