Fixes bugs in horrible previous commit I made.