code review

reviewed code, fixed some details on handling memory and variables
Merge remote-tracking branch 'origin/slicing'