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!
I think it can't, bools will be 0s except for some indices (the selected ones) which will be one.