Refactoring to allow better separation between renders and gm