Fix position issues
Create on ending functions
Reorganize grid code