some fixes

some things I did you might want to merge back, they are mostly bugfixes on issues I had and/or cleanup.