A few minor fixes & refactorings