Cleaned up code to stay DRY. Memory writing

Code is more DRY now,
memory writing for all weapons is finished.