Re-apply of longentropysel fix

Change-Id: Id90a06d58c21086b82a544eef59a000dc67e4f7b