bugfixes and error catching for filesystem ops