Added comments, changed structure and names