Revised and added tests.