Improved slice and index handling