Several bug fixes from initial testing