A revert and bug fixes