Fixed calculating paths. Server took long to load in some maps and had memory leaks.

Signed-off-by: Zyk <zyk6870@gmail.com>