Backpack code

This also reintroduces some old code which was removed in commit 40da2081f548562d6c6cf29b63cc62a346ce5948