Setting title based on file name, fixing error handling