Fixing bugs and errors