Fixed bugs in add()
Fixed minor bugs