Refactored trackhub code