Add comments, and additional optimization