Issue410

and also some clean up (removing code that was not being used and required a lot of if's).

@josenavas, can you check if this solves the issue? Thanks!
Have you tried to use `np.in1d` and `np.where`?