Implement Delete() method and fixed bugs generated by it. #1