Small Bugfixes in file handling