Fixes bugs and