Added fix for #304 and #305