1. Some code fixes.
2. Updated unit tests.