Added functions and simple test code.