Refactor initialization logic
Fix grid initialization logic and make size configurable