Improve weapon handling code