Finished implementation of functions, testing