Added diagram labels and fixed some minor bugs.