Incorporating Slavi's patch #6