clean up
added checks for filename and writeablility of the path
passing all error messages back to calling function to set them in ticket