I've roughed out the general slicing algorithm, but it still needs work.
I've left some TODOs in the code where improvements are needed.