fixed two bugs

- did not compute distance of axis plane correctly
- can now handle empty stacks correctly
two more bugs fixed

and it works!