start refactoring, wait for some hours...
added memory cleanup and refactored code