Cleanup and Unloading support

Items need to expire even if they're unloaded, otherwise you'll end up
with eternal entities just because the player signed off before the ones
around them expired.

Also holy crap this code is messy. Refactored a lot of the deeply nested
copy/pasted code into named functions.

This might not work at all. Committing before testing.