Implemented the first run of functions, and some tests.

More tests to come.