Fixed a lot of things. This commit is a working version...