Adds documentation and puts functionality in separate file