Added more comments and changed tabs to spaces

Added even more comments to functions and changed all the indentation from tabs to 4 spaces.