Changed convolution implementation to work properly but less efficient