Added utility function appendFilename and fixed up some errors.