Reduced number of functions and added tests.