Refactored grid methods, renamed some variables for clarity