Implements delete, fixes minor bugs.