Improve weapon handling code (fixes #14)