Refactor gradient model selection

- still not ready, just for comments.