Various bugfixes

Two small fixes, taking the liberty of merging them myself...