Remove remove from end optimization

Broken
Refactor and clean up
Clean up
Refactor