Added prototypes, implemented main() and introduced namespace.