Memory Fixes

* Fixes to memory on all backends
* Fixes to reference counting of array pointers
* Fixes to dim checking for element wise ops
* Fixed segfaults in copy

Fixes #228 
Fixes #243 
Fixes #251