Rearrange methods and add some documentation