Refactoring & Trying out mem leak bug fixes