Rearrange code to make it actually callable from outside.