Fixed various bugs, added exceptions, checks that index is either a numpy array or scalar.