Delete bug fixed, contract bug fixed

need to be tested some more