Fixes to make it work as a file