Prevented segfault at map borders. Still bugged though.