Fix up examples, add main function