Added delete functions and some minor fixes