Fixes bugs in previous commit