Modified internal functions to use less SRAM