Initial commit taken from recursive branch of FoG