Imported from https://github.com/hongyi-zhang/Fixup