Removes unnecessary imports, merges some lines