Merge pull request #206 from pavel-paulau/mem

Improve memory debugging facilities