Solved a critical problem with newer versions of numpy (see comments on
the code).