some more changes to the script. still not completely ready, but getting there.