Move init code into onload