replaced staticGrid with hashing structure to avoid occasional segfault and some formatting