Implement and fix #17
Refactor and fix slicing. Fixes #16