gridseed: Refactor code to clean up and organize