Changed the way onload handlers are being attached