Fixing bugs and removing unnecessary code