Separate main() to allow for external inclusion