Major refactor
Fixed up some numpy dimensional issues using keepdims argument to np.sum etc.
Cleaned up dimension manipulation
Replaced expand_dims with keep_dims=True
Updated examples to new API
Merged