Added comments and tried to solve some ambiguous things.