Final Version

Too tired to do comprehensive tests.