Memory leak solved; other small fixes.