minor tweaks & I/O refactoring