Add some comments and an init function. Changed 'main' to 'update'