Cleaned up leakage and general warnings.

Unused variables gone and memory leakage cleared. Unused imports as
well.