Fixing an issue with sampling and making morse logic more robust