Some cleanup for old codes
Some cleanup
Merged conflicts
Moved test codes in better places