Refactor more to typescript.