Finished implementation and tests