Add comments, logically reorder code