Improved addPath and reduced nesting
Added sanitizeFilePath method.