Bugfixes #166 and #169