Added detailed comments

+ minor changes to the rebuild function