Minor Refactorings and Fixes