Adding logging; fixing minor bugs.