Revert c0d6537..d20232f

This rolls back to commit c0d65376fc68594ce08696313d49bab43645c153.
re-based and fixed bugs