Implemented update and bubbleDown, along with some helper functions