Add cross-iframe functionality; some refactoring.