Fixes #23, small bugs regarding index computation.