Stability improvement. also makes debugging easier (related to #149). Should be merged into the trunk after testing.