Condensed to one file. Working program.