fix for bug #56 and #79