remove optimization to help debugging
fix some bugs