Simplify 'last' implementation (extract part into utils). Closes #6