large updates to the code to conform to the paper