Refactered to put localdata in a seperate module