Updated to Foundation 5

Made some major changes to core code. need to branch from here now.