Improved many parts and fixed many unit tests.