Refactor code to be in a class; update documentation