Some Bugfixes

The bugfixes appears in the commit messages. @Eslamunto