Fixed some bugs Matthew found.