Refactor and additions for better RAM Memory performance