Refactored memory block code.