Move some code around.
Notes about second attempt