Small fixes, refactorings