major fix to gradient calculation - only issue seems to be normal transformation; can move things to the border without any gap now; hight memory use is still a concern