Added extra error handling and debugging

TODO: Finish the iframe implementation...