Fixed a couple of minor issues

Hi Benjamin,

I've had a closer look at your PR and fixed a couple of minor issues. I would like you to have a look at them especially the ones where I restored some functionality that has already been in the original code that you removed (e.g. in d922530955f0becd315a381a915d6167658373f0). Did you remove that intentionally or not?