Updated comments, and fixed some minor bugs.