Added logic for checking NumPy version together with some ifdefs for version >= 1.7.
  -- Also removed depcrecated C-API syntax.