Added delete functionality. Fixed bugs.