Implemented changes suggested by Cooper

Also added the beginning of loop compression.