Fixes #785: Moved canonicalize_paths function to a separate file