Update

Fixed live preview
Added a more robust algorithm to find the mode.