Fixed numpy related bugs