fix bugs when included in iframe/etc