Rewrote the data conversion logic in ajax. Should be cleaner and faster.