Finished implementing the ideas of stegeman.