Some improvements

A few things that had to be done and a possible bugfix.