Updated to use Foundation and a few other things.