lots of bugfixes

first time the program actually runs