Fixes bugs introduced from previous commit