Fixing bugs + warnings