Fix for #156 and #157