I think I might've found the problem with the teleporting problem. The array that I store my monster TIDs has empty elements. I don't know why though
http://hastebin.com/dehevifera.avrasm
In the first step, I make an empty integer array of 48 elements. Then, I assign the values 320 to 367 to them in order. In the second step, I shuffle it with Fisher-Yates. No clue why there would be any zeroes remaining.