fix memory corruption bugs; fix minion equipment handling