removed unused imports, fixed exception

ArrayIndexOutOfBoundsException was thrown because labeling don't always
start at 0, fixed by subtracting ii.min(0) and ii.min(1).