Added comments and some cleaning.