move grid template into JS, better class names, style and performance improvements