Copy some code and implement some new stuff.