bugfixes as per github issues