Improved error handling

Can handle invalid links.