Added comments and cleaned a bit