Removed most foundation dependencies, cleaned up unused code