Improved error handling, added fsockopen download support if curl is unavailable