Refactor + document a little