added std umask ops around some I/O
More tidyup.
WIP