added inventory/damage functions and some other efficiency changes