more bug fixes from prev commit