Minor changes
After resolve
Added some tests, corrected some bugs, cleaned some code.